package com.learn.xueer.ui.adapter

import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.learn.xueer.R
import com.learn.xueer.data.model.bean.UnitWordResponse

class UnitWordsAdapter(data: ArrayList<UnitWordResponse>) :
    BaseQuickAdapter<UnitWordResponse, BaseViewHolder>(R.layout.item_unit_words, data) {
    override fun convert(holder: BaseViewHolder, item: UnitWordResponse) {
        holder.setText(R.id.title, item.resourceName)
        if (item.moduleName.contains("跟读")) {
            holder.setImageResource(R.id.icon, R.mipmap.icon_record)
        } else {
            holder.setImageResource(R.id.icon, R.mipmap.icon_unit_listen)
        }
        holder.setText(R.id.wordType, item.moduleName)
        if (item.moduleName.contains("单词跟读")) {
            holder.setBackgroundResource(R.id.wordType, R.drawable.word_type1)
            holder.setTextColor(R.id.wordType, ContextCompat.getColor(context, R.color.ff9917))
        } else if (item.moduleName.contains("单词跟读")) {
            holder.setBackgroundResource(R.id.wordType, R.drawable.word_type2)
            holder.setTextColor(R.id.wordType, ContextCompat.getColor(context, R.color._0287FD))
        } else {
            holder.setBackgroundResource(R.id.wordType, R.drawable.word_type3)
            holder.setTextColor(
                R.id.wordType,
                ContextCompat.getColor(context, R.color.colorPrimary)
            )
        }
    }
}